﻿using ASmile.Com;
using ASmile.Com.Da;
using ASmile.Com.Menu;
using ASmile.DBModel;
using Microsoft.AspNetCore.Mvc;

namespace ASmile.Web.ApiControllers.SysManage
{
    /// <summary>
    /// 菜单维护
    /// </summary>
    [Route("api/SysManage/[controller]/[action]")]
    [ApiExplorerSettings(GroupName = "SysManage")]
    public class MenuController : BaseApiController<MenuBLL>
    {
        /// <summary>
        /// 获取所有菜单
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_Menu> GetAllMenus()
        {
            return BLLObj.GetAllMenus();
        }

        /// <summary>
        /// 菜单分类列表（非菜单的树形结构）
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_Menu> GetTreeData()
        {
            return BLLObj.GetTreeData();
        }

        /// <summary>
        /// 新增树
        /// </summary>
        [HttpPost]
        public ApiResult<string> AddTree(Sys_Menu m)
        {
            return BLLObj.AddTree(m);
        }
        /// <summary>
        /// 编辑树
        /// </summary>
        [HttpPost]
        public ApiResult<string> EditTree(Sys_Menu m)
        {
            return BLLObj.EditTree(m);
        }
        /// <summary>
        /// 删除树
        /// </summary>
        [HttpPost]
        public ApiResult DelTree(Sys_Menu m)
        {
            return BLLObj.DelTree(m);
        }

        [HttpPost]
        public ApiResult<string> AddMenu(Sys_Menu m)
        {
            return BLLObj.AddMenu(m);
        }

        [HttpPost]
        public ApiResult<string> EditMenu(Sys_Menu m)
        {
            return BLLObj.EditMenu(m);
        }

        [HttpPost]
        public ApiResult DelMenu(Sys_Menu m)
        {
            return BLLObj.DelMenu(m);
        }

        /// <summary>
        /// 根据父级Id获取所有子菜单
        /// {PId:"父级Id",SearchValue:"搜索值"}
        /// </summary>
        [HttpPost]
        public ApiResultList<Sys_Menu> GetMenus(ArgSearchMenu arg)
        {
            return BLLObj.GetMenus(arg);
        }
        /// <summary>
        /// 交换两个记录的排序
        /// </summary>
        [HttpPost]
        public ApiResult SwapOrderNo(ArgSwapOrderNo arg)
        {
            return BLLObj.SwapOrderNo(arg);
        }
        /// <summary>
        /// 更新排序
        /// </summary>
        [HttpPost]
        public ApiResult SetOrderNo(ArgSetSortNo arg)
        {
            return BLLObj.SetOrderNo(arg);
        }
        /// <summary>
        /// 重置父级节点
        /// </summary>
        [HttpPost]
        public ApiResult SetParent(ArgSetParent arg)
        {
            return BLLObj.SetParent(arg);
        }
    }
}